import { useEffect } from 'react'
import styled from 'styled-components'
import { useNavigate } from 'react-router-dom'
import { Router } from '../../router'
import { checkUserValid } from '../../utils/user'
import { isSupport } from '../../utils/check'

const Box = styled.div`
    background-color: ${prop => prop.theme.background.launch};
    width: 100%;
    height: 100%;
    position: absolute;
`

const Launch: React.FC = () => {
    const navigate = useNavigate()

    useEffect(() => {
        if (isSupport()) {
            navigate(checkUserValid() ? `${Router.Home}?tabbar=true` : Router.Login, { replace: true })
        } else {
            navigate(Router.Unsupport)
        }
    }, [navigate])
    return <Box ></Box>
}

export default Launch